﻿using SketchUpAPI.NET.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpAPI.NET.SketchUp.Exception
{
    public static class SketchUpExceptionHelper
    {
        /// <summary>
        /// 抛出异常
        /// </summary>
        /// <param name="result"></param>
        public static void ThrowSUResult(SUResult result)
        {
            switch (result)
            {
                case SUResult.SU_ERROR_NONE:
                    // 成功，不抛出异常
                    break;
                case SUResult.SU_ERROR_NULL_POINTER_INPUT:
                    throw new System.Exception("输入参数为 Null");
                case SUResult.SU_ERROR_INVALID_INPUT:
                    throw new System.Exception("输入对象无效");
                case SUResult.SU_ERROR_NULL_POINTER_OUTPUT:
                    throw new System.Exception("输出参数为 Null");
                case SUResult.SU_ERROR_INVALID_OUTPUT:
                    throw new System.Exception("未能正确创建对象，输出参数为 Null");
                case SUResult.SU_ERROR_OVERWRITE_VALID:
                    throw new System.Exception("输入对象已经设置为 VALID");
                case SUResult.SU_ERROR_GENERIC:
                    throw new System.Exception("未指定的错误");
                case SUResult.SU_ERROR_SERIALIZATION:
                    throw new System.Exception("在加载或保存文件期间发生错误");
                case SUResult.SU_ERROR_OUT_OF_RANGE:
                    throw new System.Exception("输入参数超出允许值范围。");
                case SUResult.SU_ERROR_NO_DATA:
                    break;
                case SUResult.SU_ERROR_INSUFFICIENT_SIZE:
                    throw new System.Exception("输出参数的大小不足");
                case SUResult.SU_ERROR_UNKNOWN_EXCEPTION:
                    throw new System.Exception("发生未知异常");
                case SUResult.SU_ERROR_MODEL_INVALID:
                    throw new System.Exception("请求的模型无效，无法加载");
                case SUResult.SU_ERROR_MODEL_VERSION:
                    throw new System.Exception("由于版本无效，无法加载或保存模型");
                case SUResult.SU_ERROR_LAYER_LOCKED:
                    throw new System.Exception("正在修改的图层被锁定");
                case SUResult.SU_ERROR_DUPLICATE:
                    throw new System.Exception("请求的操作将导致重复数据");
                case SUResult.SU_ERROR_PARTIAL_SUCCESS:
                    throw new System.Exception("请求的操作未完全完成，但返回了中间成功结果");
                case SUResult.SU_ERROR_UNSUPPORTED:
                    throw new System.Exception("不支持请求的操作");
                case SUResult.SU_ERROR_INVALID_ARGUMENT:
                    throw new System.Exception("参数包含无效信息");
                case SUResult.SU_ERROR_ENTITY_LOCKED:
                    throw new System.Exception("正在修正的实体被锁定");
                case SUResult.SU_ERROR_INVALID_OPERATION:
                    throw new System.Exception("请求的操作无效");
                default:
                    break;
            }
        }
    }
}